<?php
/**
 * CreateTime: 2023/11/15 10:17
 * User:LinQ
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            // 数据库基本配置
            $table->engine = 'InnoDB';
            $table->unique('union_id','idx_u_union_id');
            // 数据库字段
            $table->id('user_id')->comment("用户id");
            $table->integer('com_id')->nullable(false)->comment("用户所属公司id");
            $table->string('name',20)->nullable(false)->comment("用户名");
            $table->string('account')->nullable(false)->comment("用户账号");
            $table->string('password')->nullable(false)->comment("用户密码");
            $table->string('email',50)->nullable()->comment("用户邮箱");
            $table->string('phone',20)->nullable()->comment("用户手机号");
            $table->integer('leader_id')->nullable()->comment("直属领导id");
            $table->string('union_id',50)->nullable(false)->comment("用户uuid");
            $table->tinyInteger('enable_status')->default(2)->nullable(false)->comment("用户启用状态 1启用 2已禁用");
            $table->tinyInteger('status')->default(2)->nullable(false)->comment("用户状态 1正常 2已删除");
            $table->text('pu_key')->nullable(false)->comment("用户公钥");
            $table->text('pv_key')->nullable(false)->comment("用户私钥");
            $table->timestamp('staff_last_login_time')->nullable()->comment("用户最后登录日期");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
};
